﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoShopping.Model;

namespace GoShopping.BLL.Orders
{
    public class ReturnPrtsRecordsBean
    {
        public IList<ReturnPrtsRecords> GetAll()
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.ReturnPrtsRecords).ToList<ReturnPrtsRecords>();
        }

        public ReturnPrtsRecords GetOne(int invoiceID)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.ReturnPrtsRecords).Where(
                GoShoppingOrderNBear.ReturnPrtsRecords.ID == invoiceID).ToSingleObject<ReturnPrtsRecords>();
        }

        public ReturnPrtsRecords GetByOrderCode(int orderCode)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.ReturnPrtsRecords).Where(
                GoShoppingOrderNBear.ReturnPrtsRecords.OrderID == orderCode).ToSingleObject<ReturnPrtsRecords>();
        }

        public int Insert(ReturnPrtsRecords invoice)
        {
            return Databases.DBGoShoppingOrder.Insert(
                GoShoppingOrderNBear.ReturnPrtsRecords).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.IsInsurance, invoice.IsInsurance).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.OrderID, invoice.OrderID).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.RecordPerson, invoice.RecordPerson).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.Remark, invoice.Remark).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.ReturnAddress, invoice.ReturnAddress).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.ReturnDate, invoice.ReturnDate).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.Returner, invoice.Returner).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.ReturnFee, invoice.ReturnFee).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.ReturnType, invoice.ReturnType).AddColumn(
                GoShoppingOrderNBear.ReturnPrtsRecords.ReturnUser, invoice.ReturnUser).ExecuteReturnAutoIncrementID(
                GoShoppingOrderNBear.ReturnPrtsRecords.ID);
        }
    }
}
